/**
 * 
 */
package org.yelongframework.model.support.mybatis.jdbc.executor;

import java.util.Objects;

import org.apache.ibatis.session.SqlSession;
import org.yelongframework.core.sql.result.builder.SqlResultBuilder;
import org.yelongframework.core.sql.statement.builder.StatementBuilder;
import org.yelongframework.lang.Nullable;
import org.yelongframework.sql.executor.DataSourceProperties;

/**
 * 使用mybatis原生数据库连接方式的实现SQL执行操作，通过sqlSession获取connection对象进行操作，这个不会经过mybatis的框架
 * 
 * @since 1.0.0
 */
public class DefaultMybatisJdbcSqlExecutor extends AbstractMybatisJdbcSqlExecutor {

	/** SQL会话 */
	private final SqlSession sqlSession;

	/** 数据源属性 */
	@Nullable
	private final DataSourceProperties dataSourceProperties;

	// ==================================================构造器==================================================

	/**
	 * @param sqlSession           SQL会话
	 * @param dataSourceProperties 数据源属性
	 * @param statementBuilder     声明构建器
	 * @param sqlResultBuilder     SQL结果构建器
	 */
	public DefaultMybatisJdbcSqlExecutor(SqlSession sqlSession, @Nullable DataSourceProperties dataSourceProperties,
			StatementBuilder statementBuilder, SqlResultBuilder sqlResultBuilder) {
		super(statementBuilder, sqlResultBuilder);
		this.sqlSession = Objects.requireNonNull(sqlSession, "sqlSession");
		this.dataSourceProperties = dataSourceProperties;
	}

	// ==================================================数据源配置==================================================

	@Override
	public DataSourceProperties getDataSourceProperties() {
		return dataSourceProperties;
	}

	// ==================================================SQL会话==================================================

	@Override
	public SqlSession getSqlSession() {
		return this.sqlSession;
	}

}
